<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div role="form" class="form-inline" id="applayAllocationForm" style="display: none;">
    <div class="form-group">
    	<label class="sr-only">派单数量：</label>
        <input type="text" placeholder="输入派单数量" id="allocationNum" name="allocationNum" class="form-control"/>
    </div>
</div>
<!-- 车型选择 -->
<script type="text/javascript">
//申请派单
function applayAllocation(url){
	layer.prompt({
	  title:'申请派单',
	  content: $('#applayAllocationForm'),
	  end:function(){
		 $('#allocationNum').val('');
	  },
	  yes: function(index, layero){
			var allocationNum = $('#allocationNum').val();
	    	if(allocationNum==""){
				layer.tips("不能为空", '#allocationNum', {time:1500});
				return;
			}
	    	
    		if(allocationNum <= 0){
				layer.tips("不能小于0", '#allocationNum', {time:1500});
				return;
			}
    		
    		if(allocationNum > 100){
				layer.tips("不能大于100", '#allocationNum', {time:1500});
				return;
			}
    		
    		var bankNum ='^[0-9]*[1-9][0-9]*$';
    		
    		if(!allocationNum.match(bankNum)){
				layer.tips("请输入正整数", '#allocationNum', {time:1500});
				return;
			}
    		applayAllocationAction(allocationNum,url, function(){
    			layer.close(index);
    		});
	  }
	}); 
}
	 //申请分配
    function applayAllocationAction(allocationNum,url,fn){
    	 $.dpAjax({
				show:false,
		 		url: url,
				data:{allocationNum:allocationNum},
				success: function(datas){
	 			  if(datas.flag == "100100") {
	 				 layer.msg("申请派单成功!", {icon: 6});
	 				 if(fn){
	 					 fn();
	 				 }
	 				 refresh();
				     return;
				   }
				   if(datas.flag == "100200") {
					  $.fn.showDatas({"datas":datas});
	             	  return;
	               }
				layer.msg(datas.message, {icon: 2});
	         }
	 	 });
    }
</script>